<template>
	<view class="content">
		<!-- 第一块内容 -->
		<view class="comman">
			<text>当前选择题库为：{{category_title}}</text>
		</view>
		<!-- 第二块内容 -->
		<view class="category">
			
			<view class="item" v-for="(item,index) in list" :key="index" @click="jump(item.url)">
				<view class="item_top">
					<image class="icon_img" :src="item.icon"></image>
				</view>
				<!-- <text class="item_bottom">{{item.name}}</text> -->
				<button class="item_bottom" open-type="getUserInfo" @getuserinfo="getUserInfo">{{item.name}}</button>
			</view>
			
			
			
			
			
		</view>
		<!-- 第三块内容 -->
		<view class="qhtk">
			<view class="qhtk_left">
				<view class="qiehuan_icon">
					<image class="qiehuan_icon_img" src="../../static/qiehuan.png"></image>
				</view>
				<text>切换题库</text>
			</view>
			<view class=qhtk_right @click="tocategory">
				<text style="font-size: 12px;">{{category_title}}</text>
				<text style="margin-left:5px;">></text>
			</view>
		</view>
		<!-- 第四块内容 -->
		<view class="scksm" @click="tocategory">
			<view class="scksm_left">
				<view class="icon">
					<image class="icon_img" src="../../static/xiaochengxu.png"></image>
				</view>
				<text>生成考试码</text>
			</view>
			<view class="scksm_right">
				<text>></text>
			</view>
			
		</view>
	</view>
</template>

<script>
	import unils from "../../unils/utils.js"
	export default {
		data() {
			return {
				category_title: '未选择题库',
				list:[
					{
						"name":"在线考试",
						'icon':"../../static/kaoshi.png",
						'url':"../kaoshi/kaoshi"
					},
					{
						"name":"顺序练习",
						'icon':"../../static/lianxi.png",
						'url':","
					},
					{
						"name":"在线考试",
						'icon':"../../static/kaoshi.png",
						'url':","
					},
					{
						"name":"在线考试",
						'icon':"../../static/kaoshi.png",
						'url':","
					},
					{
						"name":"在线考试",
						'icon':"../../static/kaoshi.png",
						'url':","
					}
				],
			}
		},
		onLoad() {
			let categoryName = uni.getStorageSync('category');
			this.category_title = categoryName;

		},
		onReady() {
			
		},
		onShow(option) {
			
		},
		methods: {
			getUserInfo(e){
				unils.getUserInfo(e);
				console.log('sdfsdfsfdsdfsdf');
			},
			jump(tourl){
				// unils.getUserInfo();
				// unils.isGetAutoSettion('scope.userInfo').then(function (isUser){
				// 	if(isUser){
				// 		console.log("获取到授权");
				// 		uni.authorize({
				// 		    scope: 'scope.userLocation',
				// 		    success() {
				// 		        uni.getLocation()
								
				// 		    }
				// 		})
				// 		// uni.getUserInfo({
				// 		// 	      provider: 'weixin',
				// 		// 	      success: function (infoRes) {
				// 		// 	        console.log('用户昵称为：' + infoRes.userInfo.nickName);
				// 		// 	      }
				// 		// 	    })
				// 	} else {
				// 		console.log("没有获取到授权");
				// 	}
				// })
				//判断是否活动授权
				// if(unils.isGetAutoSettion('scope.userInfo')){
				// 	console.log('=============');
				// 	uni.getUserInfo({
				// 	      provider: 'weixin',
				// 	      success: function (infoRes) {
				// 	        console.log('用户昵称为：' + infoRes.userInfo.nickName);
				// 	      }
				// 	    })
				// } else{
				// 	uni.authorize({
				// 	    scope: 'scope.userInfo',
				// 	    success() {
				// 	        uni.getUserInfo()
				// 	    }
				// 	})
				// 	// uni.authorize
				// }
				// console.log(tourl);
				uni.navigateTo({
					url:tourl
				})
			},
			tocategory(){
				uni.navigateTo({
					url:"../switchcategory/switchcategory"
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		// padding: 0 10px;
		
		.comman{
			font-size: 12px;
			height:40px;
			line-height: 40px;
			margin-bottom: 10px;
			display: flex;
			align-items: center;
			justify-content: center;
			background-color: #F1F1F1;
			
		}
		.qhtk{
			display: flex;
			height:40px;
			line-height: 40px;
			background-color: #F1F1F1;
			margin-bottom: 10px;
			font-size:14px;
			.qhtk_left{
				display: flex;
				width:100%;
				align-items: center;
				padding-left: 15px;
				.qiehuan_icon{
					display: flex;
					width:20px;
					height:20px;
					border-radius: 15px;
					background: #f07373;
					margin-right: 10px;
					justify-content: center;
					align-items: center;
					.qiehuan_icon_img{
						width:16px;
						height:16px;
						// padding: 3px;
						// padding-bottom: 3px;
					}
				}
				
			}
			.qhtk_right{
				flex-shrink: 0;
				padding-right:15px;
				color:#999999;
			}
			
		}
		.scksm{
			// display: flex;
			display: flex;
			height:40px;
			line-height: 40px;
			background-color: #F1F1F1;
			margin-bottom: 10px;
			font-size:14px;
			padding-left:15px;
			align-items: center;
			.scksm_left{
				display: flex;
				align-items: center;
				width:100%;
				.icon{
					display: flex;
					width:20px;
					height: 20px;
					border-radius: 10px;
					background-color: #007AFF;
					margin-right: 10px;
					align-items: center;
					justify-content: center;
					.icon_img{
						width:13px;
						height: 13px;
					}
				}
			}
			.scksm_right{
				flex-shrink: 0;
				padding-right: 15px;
				color:#999999;
			}
			
		}
	}
	
	.category{
		height: 70px;
		display: flex;
		align-items: center;
		background-color: #F1F1F1;
		margin-bottom: 10px;
		.item{
			width:50px;
			height: 50px;
			margin:0 8px;			
			.item_top{
				margin: 0 auto;
				background-color: #007AFF;
				width:30px;
				height: 30px;
				border-radius: 15px;
				display: flex;
				align-items: center;
				justify-content: center;
				.icon_img{
					width:20px;
					height:20px;
				}
			}
			.item_bottom{
				font-size: 11px;
				color:#999999;
			}
		}
	}
	
</style>
